<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head>
	<title>CMS</title>
	<!-- base href="./" / -->
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta name="keywords" content="Pennyrouter">
	<meta name="description" content="Pennyrouter">
	<meta name="author" content="pennysoft.net" />
	<link href="utils/img/icon.ico" rel="shortcut icon" type="image/x-icon" />
	<link href="utils/img/icon.ico" rel="bookmark" />
	<link href="utils/css/all.css" media="all" rel="stylesheet" type="text/css" />
	<script>
		if(document.cookie.indexOf("PHPSESSID") == -1){
			window.location.href="login.html";
		}
	</script>
	<script type="text/javascript" src="utils/lib/json.js"></script>
	<script type="text/javascript" src="utils/lib/net.js"></script>
	<script type="text/javascript" src="utils/lib/listeners.js"></script>
	<script type="text/javascript" src="utils/lib/pennyutils.js"></script>
	<script type="text/javascript" src="utils/lib/utils.js"></script>

	<script type="text/javascript" src="utils/lib/pennyfield.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/text.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/hidden.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/hidden_text.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/module_tree.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/module_trees.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/radio.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/audio.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/image.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/photo.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/url.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/select.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/selects.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/checkbox.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/suggest.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/system_id.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/password.js"></script>
	<script type="text/javascript" src="utils/lib/pennyfield/modify_password.js"></script>

	<script type="text/javascript" src="utils/lib/list_data.js"></script>
<style>
body{
/*background:url(../img/bg.jpg) center;*/
background:#fff;
color:#000;
font-size:10pt;
font-family:Microsoft YaHei,MS SONG,SimSun,tahoma,sans-serif;
/*width:1280px;*/
/*min-width:1280px;*/
text-align:-moz-center!important;
text-align:center;
margin:0 auto;
line-height: 150%;
}

#main{text-align:center;margin:0 auto;}
#left{}
#right{background: #f0f0f0;}

.menu{width: 80px; height: 30px; line-height: 30px; background: #666; color: #fff; margin: 5px 0; border: 1px solid #eee; border-left: 3px solid #6c0; cursor: pointer; font-weight: bold; text-align: left; padding: 0 0 0 10px;}

button{
font-family:Microsoft YaHei,MS SONG,SimSun,tahoma,sans-serif;
-webkit-border-radius: 5px;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #6c0), color-stop(0.7, #3b0));
text-shadow: 0px 0px 10px #393;
min-width: 120px;
height: 36px;
line-height: 100%;
border: 2px solid #fff;
cursor: pointer;
font-weight: bold;
font-size: 10pt;
color: #fff;
padding: 5px 10px;
margin: 5px;
}

.label{
padding: 0px 5px;
}

.input_border{
margin: 0px 5px;
padding: 0px 5px;
border-radius: 5px;

border:1px solid #aaa;

-moz-box-shadow:0px 0px 4px #ccc;
-ms-box-shadow:0px 0px 4px #ccc;
-wekit-box-shadow:0px 0px 4px #ccc;
-o-box-shadow:0px 0px 4px #ccc;
box-shadow:0px 0px 4px #ccc;
}
.input{
border:0px;
height: 28px;
line-height: 28px;
font-family:Microsoft YaHei,MS SONG,SimSun,tahoma,sans-serif;
font-size: 12pt;
}

.remind{
padding-left:15px;
text-align:left;
color:#f00;
}

.rm{padding: 0px 5px;}

.tables{border-top:1px solid #999;border-bottom:1px solid #999;}
.column{width:80px;padding:5px; margin:1px;font-size:8pt;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-left:1px solid #ccc;}
.column_text{width:70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.column_move{width:5px;height:20px;border:1px solid #eee;text-align:center;cursor:move;}
.table_header{height:35px;border:1px solid #ccc;}
.table_row{height:35px;border-left:1px solid #ccc;border-right:1px solid #ccc;border-bottom:1px solid #ccc;}

.menu_top{width: 150px; height: 30px; line-height: 30px; padding: 0 5px; margin: 0 5px; border: 1px solid #eee; border-bottom: 3px solid #6c0; cursor: pointer;}

.w1{width: 60px}
.w2{width: 80px}
.w3{width: 100px}

.row_button{width: 40px; cursor: pointer; -webkit-border-radius: 3px;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #6c0), color-stop(0.7, #3b0));
color: #fff;
padding: 0 10px;
margin: 5px;
}

.icon_sub,
.icon_image,
.icon_down,
.icon_upload,
.icon_play,
.icon_date,
.icon_time,
.icon_delete,
.icon_modify,
.icon_selected_false,
.icon_selected_true{width:22px;height:22px;cursor:pointer}

.icon_sub{background:url(utils/img/icon_sub.png) center no-repeat;}
.icon_image{background:url(utils/img/icon_image.png) center no-repeat;}
.icon_down{background:url(utils/img/icon_down.png) center no-repeat;}
.icon_upload{background:url(utils/img/icon_upload.png) center no-repeat;}
.icon_play{background:url(utils/img/icon_play.png) center no-repeat;}
.icon_date{background:url(utils/img/icon_date.png) center no-repeat;}
.icon_time{background:url(utils/img/icon_time.png) center no-repeat;}
.icon_delete{background:url(utils/img/icon_delete.png) center no-repeat;}
.icon_modify{background:url(utils/img/icon_modify.png) center no-repeat;}
.icon_selected_false{background:url(utils/img/icon_selected_false.png) center no-repeat;}
.icon_selected_true{background:url(utils/img/icon_selected_true.png) center no-repeat;}

.input_icon{height: 28px;line-height: 28px;}

.first_page_button,
.prev_page_button,
.next_page_button,
.last_page_button,
.page_this_button,
.page_button{padding:5px 10px;margin:5px;cursor:pointer;border:1px solid #aaa;color:#666}
.page_button{text-decoration:underline;border:1px solid #ccc;color:#aaa;}

.radio,
.radioed{
height:28px;line-height:28px;margin:0px 10px; 0px 5px;padding:0px 5px 0px 20px;cursor:pointer;
}
.radio{background:url(utils/img/icon_radio_false.png) center left no-repeat;}
.radioed{background:url(utils/img/icon_radio_true.png) center left no-repeat;}
.checkbox,
.checkboxed{
height: 28px;line-height:28px;margin:0px 10px; 0px 5px;padding:0px 5px 0px 20px;cursor:pointer;
}
.checkbox{background:url(utils/img/icon_selected_false.png) center left no-repeat;}
.checkboxed{background:url(utils/img/icon_selected_true.png) center left no-repeat;}

.select_items{background:#f6f6f6;width:100%;}
.select_item{width:100%;overflow:hidden;}
.select_item_text{height:20px;padding:10px;text-align:left;}

.selects_items{background:#f6f6f6;width:100%;}
.selects_item{width:100%;overflow:hidden;}
.selects_item_text{padding:5px;}

.suggest_list{background:#fff;padding:5px;margin:5px;border:1px solid #ccc;}
.suggest_item{background:#fff;padding:5px;margin:5px;text-align:left;}


.module_trees_selector{background:#fcfcfc;width:100%;}

.module_tree_selector{background:#fcfcfc;width:100%;}

.form_win{
position:absolute;
border:5px solid #bbb;
background:#fff;
left:0;
top:0;
z-index:9000;
margin:0;
padding:1px;
display:none;
}

.form_win_title{
width:100%;
text-align:right;
cursor:move;
background: #f0f0f0;
}


.icon_button{
font-size:2pt;
height:20px;
width:20px;
cursor:pointer
}

.up_icon{background:url(utils/img/cms_icon_up.gif) no-repeat center;}
.down_icon{background:url(utils/img/cms_icon_down.gif) no-repeat center;}

.hide_icon{background:url(utils/img/cms_icon_hide.gif) no-repeat center;}
.zoom_icon{background:url(utils/img/cms_icon_zoom.gif) no-repeat center;}
.close_icon{background:url(utils/img/cms_icon_close.gif) no-repeat center;}


.image_items{width:300px;border:1px solid #999;background:#fff;}
.image_items .image_item_div{border:1px solid #ccc;background:#eee;padding:5px;margin:5px;}
.image_items .image_item_img{width:40px;height:40px;padding:3px;}

.image_item{width:70px;border:1px solid #999;background:#fff;}
.image_item .image_item_div{border:1px solid #ccc;background:#eee;padding:5px;margin:5px;}
.image_item .image_item_img{width:40px;height:40px;padding:3px;}


.photo_items{width:300px;border:1px solid #999;background:#fff;}
.photo_items_div{border:1px solid #ccc;background:#eee;padding:5px;margin:5px;}
.photo_items_img{width:40px;height:40px;padding:3px;}
.photo_items_append{width:40px;height:40px;background:#fff;line-height:40px;}

</style>

</head>
<body>

<div id="all_content">

<div id="main" class=" bgc3">

<div id="left" class="l">

<!--<div class="menu" onclick="changeModule('words', '资料');">资料</div>-->
<!--<div class="menu" onclick="changeModule('chapters', '课本');">课本</div>-->

<div class="menu" onclick="changeModule('market', '市场');">市场</div>
<div class="menu" onclick="changeModule('shop', '店铺');">店铺</div>
<!--<div class="menu" onclick="changeModule('merchandise', '产品');">产品</div>-->

<div class="menu" onclick="changeModule('resource', '多语言');">多语言</div>
<div class="menu" onclick="changeModule('key_value', '下拉选项');">下拉选项</div>

<div class="menu" onclick="changeModule('admin_user', '用户管理');">用户管理</div>
<div class="menu" onclick='new net.ContentLoader("dao/logout.php", function(){
	document.cookie = "";
	window.location.href = "login.html";
	},"", true);'>退出登录</div>


<a class="cf" href="./dao/write.php" target="_blank">同步</a>

</div>

<!-- LEFT. BEGIN -->

<div id="right" class="r">


<div class="p10">
<div id="data">

<div class="bgcf m10 tl">

	<div class="p10">
	<button type="button" onclick="loadDataAction(-1)">增加&nbsp;&nbsp;<span id="form_title">form_title</span></button>

	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input id="search_form.search_input_text" class="input_border input" value="" />
	<button class="button" onclick="queryDatasAction()">搜索</button>
	<button class="button" onclick="loadAllDatasAction()">全部</button>
	</div>
</div>

<div class="bgcf m10">
<div id="pages" class="p5"></div>
<div class="p10">
<div id="datas" style="width:100%; overflow:scroll;"></div>
</div>
</div>

<div class="dn">
<input id="operator" class="input" />
<input id="query" class="input" />
</div>

<!--
<div>

</div>
<div id="form_div"></div>
<div>
	<button type="button" onclick="$($MODULE_NAME_LOWER+'._'+$MODULE_NAME_LOWER+'_id').value=''">复制</button>
	<button type="button" onclick="updateDataAction()">保存</button>
</div>
-->
</div>
</div>

</div>

<!-- LEFT. END -->

<div class="c"></div>

</div>

</div>

<!--
<audio controls="controls" autoplay="autoplay" class="dn">
<source src="000001.MP3" type="audio/mpeg">
</audio>
-->

</body>
</html>

<script type="text/javascript">
<!--//--><![CDATA[//><!--
var $MODULE_NAME_LOWER=null;

var $DATA_COLUMNS=null;

function queryDatasAction () {
	var $search_value=$("search_form.search_input_text").value;
	if ($search_value.length==0) {
		return;
	}
	var $columns=$FORM_CONFIG[$MODULE_NAME_LOWER];
	var $field_name=[];
	for (var $col_index=0; $col_index<$columns.length; $col_index++) {
		$field_name[$field_name.length]=$columns[$col_index]["_field_name"];
	}

	new net.ContentLoader("dao/query.php", function(){
//		alert("queryDatasAction : "+this.request.responseText);
		try {
			var $json_obj=JSON.parse(this.request.responseText);
			setAllDataRow($json_obj);
		} catch ($err) {
			alert("Error connect!\nerr:"+$err+"\nerr.message:"+$err.message+"\n"+this.request.responseText);
		}
	},
	"&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER)+
	"&field_name="+encodeURIComponent($field_name.join(","))+
	"&field_value="+encodeURIComponent($search_value)+
	"&operator="+encodeURIComponent("like")
	, true);
}
function loadAllDatasAction () {
	new net.ContentLoader("dao/load_all_datas.php", function(){
//		alert("loadAllDatasAction : "+this.request.responseText);
		try {
			var $json_obj=JSON.parse(this.request.responseText);
			setAllDataRow($json_obj);
		} catch ($err) {
			alert($err+"\r\n"+this.request.responseText);
		}
	},
	"&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER)
	, true);
}
function loadDatasAction () {
	new net.ContentLoader("dao/load_datas.php", function(){
//		alert("loadDatasAction : "+this.request.responseText);
		var $json_obj=JSON.parse(this.request.responseText);
		setAllDataRow($json_obj);
	},
	"&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER)+
	"&this_page="+encodeURIComponent(undefined==arguments[0]?0:arguments[0])
	, true);
}
function deleteDataAction () {
	if (!confirm("是否确认删除 "+arguments[1]+" 记录？")) {
		return;
	}
	new net.ContentLoader("dao/delete_data.php", function(){
		alert(this.request.responseText);
//		var $json_obj=JSON.parse(this.request.responseText);
//		removeDatasRow($json_obj);
	}, "&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER)+"&_"+$MODULE_NAME_LOWER+"_id="+encodeURIComponent(arguments[0]), true);
}
function loadDataAction () {
	new net.ContentLoader("dao/load_data.php", function(){
//		try {
			var $json_obj=JSON.parse(this.request.responseText);
			var $columns=$FORM_CONFIG[$MODULE_NAME_LOWER];
			for (var $col_index=0; $col_index<$columns.length; $col_index++) {
				setInputValue($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"], $json_obj[$columns[$col_index]["_field_name"]]);
			}
			showWindow($FORM_WIN[$MODULE_NAME_LOWER]);
//		} catch ($err) {
//			alert("Error connect!\nerr:"+$err+"\nerr.message:"+$err.message+"\n"+this.request.responseText);
//		}
	}, "&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER)+"&_"+$MODULE_NAME_LOWER+"_id="+encodeURIComponent(arguments[0]), true);
}
function updateDataAction () {
	var $params=[];
	var $columns=$FORM_CONFIG[$MODULE_NAME_LOWER];
	$params[$params.length]="&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER);
	for (var $col_index=0; $col_index<$columns.length; $col_index++) {
		$($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]+"_remind").innerHTML="";
		if ($columns[$col_index]["_required"] && ""==$($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]).value.trim()) {
			if ($($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]+"_remind")) {
				$($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]+"_remind").innerHTML=$columns[$col_index]["_label_name"]+"不能为空";
			} else {
				alert($columns[$col_index]["_label_name"]+"不能为空");
			}
			$($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]).value="";
			$($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]).focus();
			return;
		}
		$params[$params.length]="&"+$columns[$col_index]["_field_name"]+"="+encodeURIComponent($($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]).value);
	}

	new net.ContentLoader("dao/update_data.php", function(){
//		alert(this.request.responseText);
		var $json_obj=JSON.parse(this.request.responseText);
		setDataRow($json_obj);

		var $columns=$FORM_CONFIG[$MODULE_NAME_LOWER];
		for (var $col_index=0; $col_index<$columns.length; $col_index++) {
//			$($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"]).value="";
			setInputValue($MODULE_NAME_LOWER+"."+$columns[$col_index]["_field_name"], $json_obj[$columns[$col_index]["_field_name"]]);
		}
	},
	$params.join("")
	, true);
}
function createDataRow () {

}
function setDataRow ($tables_record) {
	for (var $row_index=0; $row_index<$TABLES_DATA.length; $row_index++) {
		if (
			$tables_record[$FORM_CONFIG[$MODULE_NAME_LOWER][0]["_field_name"]]
			==
			$TABLES_DATA[$row_index][$FORM_CONFIG[$MODULE_NAME_LOWER][0]["_field_name"]]
		) {
			$TABLES_DATA[$row_index]=$tables_record;

			$row_node=createRowNode($row_index);
			Pennyutils.setCssStyle($row_node, "width:"+$("datas").childNodes[0].offsetWidth+"px;");
			$($MODULE_NAME_LOWER+"_row_"+$row_index).parentNode.replaceChild($row_node, $($MODULE_NAME_LOWER+"_row_"+$row_index));

			return;
		}
	}

	$row_index=$TABLES_DATA.length;
	$TABLES_DATA[$row_index]=$tables_record;
	$row_node=createRowNode($row_index);
	Pennyutils.setCssStyle($row_node, "width:"+$("datas").childNodes[0].offsetWidth+"px;");
	$("datas").insertBefore($row_node, $("datas").childNodes[0].nextSibling);
}

function modifyAllDataAction () {
	var $ids=[];
	for (var $row_index=0; $row_index<$TABLES_DATA.length; $row_index++) {
		if (undefined!=$TABLES_DATA[$row_index]["selected"] && $TABLES_DATA[$row_index]["selected"]) {
			$ids[$ids.length]=$TABLES_DATA[$row_index][$FORM_CONFIG[$MODULE_NAME_LOWER][0]["_field_name"]];
		}
	}
	if ($ids.length) {

	} else {
		loadDataAction(-1);
	}
}
function deleteAllDataAction () {
	var $ids=[];
	for (var $row_index=0; $row_index<$TABLES_DATA.length; $row_index++) {
		if (undefined!=$TABLES_DATA[$row_index]["selected"] && $TABLES_DATA[$row_index]["selected"]) {
			$ids[$ids.length]=$TABLES_DATA[$row_index][$FORM_CONFIG[$MODULE_NAME_LOWER][0]["_field_name"]];
		}
	}
	if ($ids.length) {
		if (!confirm("是否确认删除 "+$ids.join(",")+" 记录？")) {
			return;
		}
		new net.ContentLoader("dao/delete_all_data.php", function(){
			alert(this.request.responseText);
		}, "&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER)+"&_"+$MODULE_NAME_LOWER+"_id="+encodeURIComponent($ids.join(",")), true);
	}
}
var $SELECTED=false;
function selectAllDataAction () {
	$SELECTED=!$SELECTED;
	var $event=Pennyutils.events.getEvent();
	Pennyutils.setClassName($event.target, $SELECTED?"icon_selected_true":"icon_selected_false");
	for (var $row_index=0; $row_index<$TABLES_DATA.length; $row_index++) {
		$TABLES_DATA[$row_index]["selected"]=$SELECTED;
		Pennyutils.setClassName($("select_datas_row_"+$row_index), $SELECTED?"icon_selected_true":"icon_selected_false");
	}
}
function selectDataAction ($row_index) {
	var $selected=undefined!=$TABLES_DATA[$row_index]["selected"]&&$TABLES_DATA[$row_index]["selected"]?false:true;
	$TABLES_DATA[$row_index]["selected"]=$selected;
	Pennyutils.setClassName($("select_datas_row_"+$row_index), $selected?"icon_selected_true":"icon_selected_false");
}

function createPages ($result_count, $show_rows, $this_page_index, $page_button_count) {
	var $page_count=$result_count%$show_rows==0?$result_count/$show_rows:parseInt($result_count/$show_rows)+1;
	$this_page_index=$this_page_index<$page_count?$this_page_index:$page_count-1;
	var $page_start_index;
	var $page_loop_length;
	if ($page_count>$page_button_count) {
		if ($this_page_index<4) {
			$page_loop_length=$page_button_count;
			$page_start_index=0;
		} else if ($this_page_index+4>$page_count-1) {
			$page_loop_length=$page_count;
			$page_start_index=$page_count-$page_button_count;
		} else {
			$page_loop_length=$this_page_index+5;
			$page_start_index=$this_page_index-4;
		}
	} else {
		$page_loop_length=$page_count;
		$page_start_index=0;
	}

	$("pages").innerHTML="";
	var $pages_node=document.createElement("div");
	var $page_node;

	$page_node=document.createElement("div");
	Pennyutils.setClassName($page_node, "l first_page_button");
	Pennyutils.events.addEventHandler($page_node, "click", new Function("loadDatasAction(0)"));
	$page_node.innerHTML="<<";
	$pages_node.appendChild($page_node);

	$page_node=document.createElement("div");
	Pennyutils.setClassName($page_node, "l prev_page_button");
	Pennyutils.events.addEventHandler($page_node, "click", new Function("loadDatasAction("+($this_page_index-1>0?$this_page_index-1:0)+")"));
	$page_node.innerHTML="<";
	$pages_node.appendChild($page_node);

	for (var $page_index=$page_start_index; $page_index<$page_loop_length; $page_index++) {
		$page_node=document.createElement("div");
		Pennyutils.setClassName($page_node, "l "+($this_page_index==$page_index?"page_this_button":"page_button"));
		Pennyutils.events.addEventHandler($page_node, "click", new Function("loadDatasAction("+$page_index+")"));
		$page_node.innerHTML=$page_index+1;
		$pages_node.appendChild($page_node);
	}

	$page_node=document.createElement("div");
	Pennyutils.setClassName($page_node, "l next_page_button");
	Pennyutils.events.addEventHandler($page_node, "click", new Function("loadDatasAction("+($this_page_index+1<$page_count?$this_page_index+1:$page_count-1)+")"));
	$page_node.innerHTML=">";
	$pages_node.appendChild($page_node);

	$page_node=document.createElement("div");
	Pennyutils.setClassName($page_node, "l last_page_button");
	Pennyutils.events.addEventHandler($page_node, "click", new Function("loadDatasAction("+($page_count-1)+")"));
	$page_node.innerHTML=">>";
	$pages_node.appendChild($page_node);

	$page_node=document.createElement("div");
	Pennyutils.setClassName($page_node, "c");
	$pages_node.appendChild($page_node);

	$("pages").appendChild($pages_node);
}

var $TABLES_DATA;
function setAllDataRow () {
//	createPages(35, 3, 2, 10);

	$TABLES_DATA=arguments[0]["results"];

	createPages(arguments[0]["result_count"], arguments[0]["show_rows"], arguments[0]["this_page"], 9);

	$("datas").innerHTML="";
//	var $json_obj=arguments[0];
	var $row_node;
	var $column_node;
	var $column_inner_node;
	var $column_icons_node
	var $column_text_node;
	var $column_icon_node;
	var $column_move_node;
	var $columns=$FORM_CONFIG[$MODULE_NAME_LOWER];

	// Title.
	$row_node=document.createElement("div");
	Pennyutils.setIdName($row_node, $MODULE_NAME_LOWER+"_header");
	Pennyutils.setClassName($row_node, "table_header");

	var $col_index;

	$col_index=0;

	$column_node=document.createElement("div");
	Pennyutils.setIdName($column_node, $MODULE_NAME_LOWER+"_header_item_"+$col_index);
	Pennyutils.setClassName($column_node, "l column "+($columns[$col_index]["_table_class"]?$columns[$col_index]["_table_class"]:""));

	$column_inner_node=document.createElement("div");
	Pennyutils.setIdName($column_inner_node, $MODULE_NAME_LOWER+"_header_text_"+$col_index);
	Pennyutils.setClassName($column_inner_node, "l column_text o");

	// Icons.
	$column_icons_node=document.createElement("div");
	Pennyutils.setClassName($column_icons_node, "o");
	Pennyutils.setCssStyle($column_icons_node, "width:100px;");

	// Delete.
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "l");

	$column_icon_node=document.createElement("div");
	Pennyutils.setClassName($column_icon_node, "icon_delete");
	Pennyutils.events.addEventHandler($column_icon_node, "click", new Function("deleteAllDataAction()"));
	$column_icon_node.innerHTML="&nbsp;";
	$column_text_node.appendChild($column_icon_node);

	$column_icons_node.appendChild($column_text_node);

	// Modify.
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "l");

	$column_icon_node=document.createElement("div");
	Pennyutils.setClassName($column_icon_node, "icon_modify");
	Pennyutils.events.addEventHandler($column_icon_node, "click", new Function("modifyAllDataAction()"));
	$column_icon_node.innerHTML="&nbsp;";
	$column_text_node.appendChild($column_icon_node);

	$column_icons_node.appendChild($column_text_node);

	// Select.
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "l");

	$column_icon_node=document.createElement("div");
	Pennyutils.setClassName($column_icon_node, "icon_selected_false");
	Pennyutils.events.addEventHandler($column_icon_node, "click", new Function("selectAllDataAction()"));
	$column_icon_node.innerHTML="&nbsp;";
	$column_text_node.appendChild($column_icon_node);

	$column_icons_node.appendChild($column_text_node);

	// Clear
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "c");
	$column_icons_node.appendChild($column_text_node);

	$column_inner_node.appendChild($column_icons_node);

	$column_node.appendChild($column_inner_node);

	$column_move_node=document.createElement("div");
	$column_move_node.innerHTML=".";
	Pennyutils.setIdName($column_move_node, $MODULE_NAME_LOWER+"_header_move_"+$col_index);
	Pennyutils.setClassName($column_move_node, "r column_move");
	Pennyutils.events.addEventHandler($column_move_node, "mousedown", new Function("handleColumnMouseDown('"+$MODULE_NAME_LOWER+"', '"+$col_index+"')"));
	$column_node.appendChild($column_move_node);

	$column_move_node=document.createElement("div");
	Pennyutils.setClassName($column_move_node, "c");
	$column_node.appendChild($column_move_node);

	$row_node.appendChild($column_node);

//	var $field_names=[];
	for ($col_index=0; $col_index<$columns.length; $col_index++) {
//		$field_names[$field_names.length]=$columns[$col_index]["_field_name"]
		if ($columns[$col_index]["_show"]) {
			$column_node=document.createElement("div");
			Pennyutils.setIdName($column_node, $MODULE_NAME_LOWER+"_header_item_"+($col_index+1));
			Pennyutils.setClassName($column_node, "l column "+($columns[$col_index]["_table_class"]?$columns[$col_index]["_table_class"]:""));
			if ($columns[$col_index]["_table_style"]) {Pennyutils.setCssStyle($column_node, $columns[$col_index]["_table_style"]);}

			$column_text_node=document.createElement("div");
			Pennyutils.setIdName($column_text_node, $MODULE_NAME_LOWER+"_header_text_"+($col_index+1));
			Pennyutils.setClassName($column_text_node, "l column_text");
			$column_text_node.appendChild(document.createTextNode($columns[$col_index]["_label_name"]));
			$column_node.appendChild($column_text_node);

			$column_move_node=document.createElement("div");
			$column_move_node.innerHTML=".";
			Pennyutils.setIdName($column_move_node, $MODULE_NAME_LOWER+"_header_move_"+($col_index+1));
			Pennyutils.setClassName($column_move_node, "r column_move");
			Pennyutils.events.addEventHandler($column_move_node, "mousedown", new Function("handleColumnMouseDown('"+$MODULE_NAME_LOWER+"', '"+($col_index+1)+"')"));
			$column_node.appendChild($column_move_node);

			$column_move_node=document.createElement("div");
			Pennyutils.setClassName($column_move_node, "c");
			$column_node.appendChild($column_move_node);

			$row_node.appendChild($column_node);
		}
	}
	$column_node=document.createElement("div");
	Pennyutils.setClassName($column_node, "c");
	$row_node.appendChild($column_node);
	$("datas").appendChild($row_node);
//	$("search").value=$field_names.join(",");
	var $width;
	$width=0;
	$col_index=0;
	$width+=$($MODULE_NAME_LOWER+"_header_item_"+$col_index).offsetWidth;
	for ($col_index=0; $col_index<$columns.length; $col_index++) {
		if ($columns[$col_index]["_show"]) {
			$width+=$($MODULE_NAME_LOWER+"_header_item_"+($col_index+1)).offsetWidth;
		}
	}
	$width+=$columns.length*3;
	Pennyutils.setCssStyle($row_node, "width:"+$width+"px;");

	// Results.
	for (var $row_index=0; $row_index<$TABLES_DATA.length; $row_index++) {
		$row_node=createRowNode($row_index);
		Pennyutils.setCssStyle($row_node, "width:"+$width+"px;");
		$("datas").appendChild($row_node);
	}
}
function createRowNode ($row_index) {
	var $columns=$FORM_CONFIG[$MODULE_NAME_LOWER];

	var $row_node=document.createElement("div");
	Pennyutils.setIdName($row_node, $MODULE_NAME_LOWER+"_row_"+$row_index);
	Pennyutils.setClassName($row_node, "table_row");

	var $col_index;

	$col_index=0

	var $column_node;
	var $column_text_node;
	var $column_icons_node;
	var $column_icon_node;

	// Process column. begin.
	$column_node=document.createElement("div");
	Pennyutils.setIdName($column_node, $MODULE_NAME_LOWER+"_column_item_"+$col_index+"_"+$row_index);
	Pennyutils.setClassName($column_node, "l column o");

	$column_icons_node=document.createElement("div");
	Pennyutils.setClassName($column_icons_node, "o");
	Pennyutils.setCssStyle($column_icons_node, "width:100px;");

	// Delete.
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "l");

	$column_icon_node=document.createElement("div");
	Pennyutils.setClassName($column_icon_node, "icon_delete");
	Pennyutils.events.addEventHandler($column_icon_node, "click", new Function("deleteDataAction('"+$TABLES_DATA[$row_index][$columns[0]["_field_name"]]+"','"+$TABLES_DATA[$row_index][$columns[0]["_label_name"]]+"')"));
	$column_icon_node.innerHTML="&nbsp;";
	$column_text_node.appendChild($column_icon_node);

	$column_icons_node.appendChild($column_text_node);

	// Modify.
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "l");

	$column_icon_node=document.createElement("div");
	Pennyutils.setClassName($column_icon_node, "icon_modify");
	Pennyutils.events.addEventHandler($column_icon_node, "click", new Function("loadDataAction('"+$TABLES_DATA[$row_index][$columns[0]["_field_name"]]+"')"));
	$column_icon_node.innerHTML="&nbsp;";
	$column_text_node.appendChild($column_icon_node);

	$column_icons_node.appendChild($column_text_node);

	// Select.
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "l");

	$column_icon_node=document.createElement("div");
//	Pennyutils.setIdName($column_text_node, "select_datas_row_"+$TABLES_DATA[$row_index][$columns[0]["_field_name"]]);
	Pennyutils.setIdName($column_icon_node, "select_datas_row_"+$row_index);
	Pennyutils.setClassName($column_icon_node, "icon_selected_false");
	Pennyutils.events.addEventHandler($column_icon_node, "click", new Function("selectDataAction('"+$row_index+"')"));
	$column_icon_node.innerHTML="&nbsp;";
	$column_text_node.appendChild($column_icon_node);

	$column_icons_node.appendChild($column_text_node);

	// Clear
	$column_text_node=document.createElement("div");
	Pennyutils.setClassName($column_text_node, "c");
	$column_icons_node.appendChild($column_text_node);

	$column_node.appendChild($column_icons_node);

	$row_node.appendChild($column_node);
	// Process column. end.

	for ($col_index=0; $col_index<$columns.length; $col_index++) {
		if ($columns[$col_index]["_show"]) {
			$column_node=document.createElement("div");
			Pennyutils.setIdName($column_node, $MODULE_NAME_LOWER+"_column_item_"+($col_index+1)+"_"+$row_index);
			Pennyutils.setClassName($column_node, "l column "+($columns[$col_index]["_table_class"]?$columns[$col_index]["_table_class"]:""));
			if ($columns[$col_index]["_table_style"]) {Pennyutils.setCssStyle($column_node, $columns[$col_index]["_table_style"]);}

			$column_text_node=document.createElement("div");
			if (undefined==$columns[$col_index]["_list_name"] || undefined==$LIST[$columns[$col_index]["_list_name"]]) {
				$column_text_node.appendChild(document.createTextNode($TABLES_DATA[$row_index][$columns[$col_index]["_field_name"]]?$TABLES_DATA[$row_index][$columns[$col_index]["_field_name"]]:"."));
			} else {
				if ($TABLES_DATA[$row_index][$columns[$col_index]["_field_name"]]) {
					var $list_value=$TABLES_DATA[$row_index][$columns[$col_index]["_field_name"]];
					for (var $list_index=0; $list_index<$LIST[$columns[$col_index]["_list_name"]].length; $list_index++) {
						if ($list_value==$LIST[$columns[$col_index]["_list_name"]][$list_index]["key"]) {
							$list_value=$LIST[$columns[$col_index]["_list_name"]][$list_index]["value"];
						}
					}
					$column_text_node.appendChild(document.createTextNode($list_value));
				} else {
					$column_text_node.appendChild(document.createTextNode("."));
				}
			}

			$column_node.appendChild($column_text_node);
			$row_node.appendChild($column_node);
		}
	}

	$column_node=document.createElement("div");
	Pennyutils.setClassName($column_node, "c");
	$row_node.appendChild($column_node);

	return $row_node;
}

var $move_table_name;
var $move_col;
function handleColumnMouseDown () {
	$move_table_name=arguments[0];
	$move_col=arguments[1];

	Pennyutils.events.addEventHandler($($move_table_name+"_header"), "selectstart", handleColumnSelectFalse);
	Pennyutils.replaceCssStyle($($move_table_name+"_header"), "-moz-user-select", "-moz-user-select:none;");

	Pennyutils.replaceCssStyle($($move_table_name+"_header_move_"+$move_col), "position", "position:absolute;");

	Pennyutils.events.addEventHandler(document.body, "mousemove", handleColumnMouseMove);
	Pennyutils.events.addEventHandler(document.body, "mouseup", handleColumnMouseUp);
}
function handleColumnMouseMove () {
	var $event=Pennyutils.events.getEvent();
	var $move=$($move_table_name+"_header_move_"+$move_col);
	var $target=$($move_table_name+"_header_item_"+$move_col);
	var $margin=0;
	var t_left=0;

	if (document.uniqueID) {
		$move.style.left=$event.clientX;
		var nLt=0;
		var offsetParent=$target;
		while (offsetParent!=null && offsetParent!=document.body) {
			nLt+=offsetParent.offsetLeft;
			if (document.uniqueID) {
				parseInt(offsetParent.currentStyle.borderLeftWidth)>0?nLt+=parseInt(offsetParent.currentStyle.borderLeftWidth):"";
			}
			offsetParent=offsetParent.offsetParent;
		}
		t_left=nLt;
	} else {
		$move.style.setProperty("left", $event.clientX+"px", "");

		t_left=$target.offsetLeft;
	}

//	$margin=$event.clientX-t_left;
	$margin=$("datas").scrollLeft+$event.clientX-t_left;

	if (($margin-2)<=0) {
//		_draggable.moveTo(_dropTarget.getLeft(), _dropTarget.getTop());
	}

//	var $saw_width=7;
	var $saw_width=7;
	// var $total_width=0;
	// for (var $index=0; $index<$move_col; $index++) {
		// $total_width+=$($move_table_name+"_header_item_"+$index).scrollWidth+",";
	// }

//	window.status=$($move_table_name+"_grid_table").scrollWidth+","+$($move_table_name+"_grid_table").scrollLeft+","+$move_col+":"+total_width;
	if ($margin>0) {
		$($move_table_name+"_header_item_"+$move_col).style.width=($margin+$saw_width)+"px";
		$($move_table_name+"_header_text_"+$move_col).style.width=$margin+"px";

		var $columns=$FORM_CONFIG[$MODULE_NAME_LOWER];
		var $width;
		$width=0;
		var $col_index;
		$col_index=0;
		$width+=$($move_table_name+"_header_item_"+$col_index).offsetWidth;
		for (var $col_index=0; $col_index<$columns.length; $col_index++) {
			if ($($move_table_name+"_header_item_"+($col_index+1))) {
				$width+=$($move_table_name+"_header_item_"+($col_index+1)).offsetWidth;
			}
			// console.log($move_table_name+"_header_item_"+($col_index+1)+":"+$($move_table_name+"_header_item_"+($col_index+1)));
		}
		$width+=100;
		Pennyutils.replaceCssStyle($("datas").childNodes[0], "width", "width:"+$width+"px;");
//		$("search").value=$width;
//		if ($("all_batch_id").value.length>0) {
//			var id_array = $("all_batch_id").value.split(",");
//			for (id in id_array) {
//				alert($move_table_name+"_column_item_"+$move_col+"_"+id_array[id]+","+$($move_table_name+"_column_item_"+$move_col+"_"+id_array[id]));
//				$($move_table_name+"_column_item_"+$move_col+"_"+id_array[id]).style.width=(margin+saw_width)+"px";
//			}
//		}
		for ($row_index=1; $row_index<$("datas").childNodes.length; $row_index++) {
			$($move_table_name+"_column_item_"+$move_col+"_"+($row_index-1)).style.width=($margin+$saw_width)+"px";
			Pennyutils.replaceCssStyle($("datas").childNodes[$row_index], "width", "width:"+$width+"px;");
		}
	}
}
function handleColumnMouseUp () {
	var $move=$($move_table_name+"_header_move_"+$move_col);
	Pennyutils.replaceCssStyle($move, "position", "position:static;");

	Pennyutils.events.removeEventHandler($($move_table_name+"_header"), "selectstart", handleColumnSelectFalse);
	Pennyutils.replaceCssStyle($($move_table_name+"_header"), "-moz-user-select", "");

	Pennyutils.events.removeEventHandler(document.body, "mousemove", handleColumnMouseMove);
	Pennyutils.events.removeEventHandler(document.body, "mouseup", handleColumnMouseUp);
}
function handleColumnSelectFalse () {
	return false;
}

function setNatDataRow () {

}

function getQueryString () {
	var reg=new RegExp("(^|&)"+arguments[0]+"=([^&]*)(&|$)", "i");
	var r=window.location.search.substr(1).match(reg);
	if (r!=null) {
		return unescape(r[2]);
	}
	return null;
}

function changeModule () {
	if ($FORM_WIN[$MODULE_NAME_LOWER]) {
		Pennyutils.hideObject($FORM_WIN[$MODULE_NAME_LOWER]);
	}
	$MODULE_NAME_LOWER=arguments[0];
	$('form_title').innerHTML=arguments[1];
	$("search_form.search_input_text").value="";
	if (undefined==$FORM_CONFIG[$MODULE_NAME_LOWER]) {
		new net.ContentLoader("dao/load_setting.php", function(){
//			alert($MODULE_NAME_LOWER+"\r\n"+this.request.responseText);
			var $json_obj=JSON.parse(this.request.responseText);
			// $DATA_COLUMNS=$json_obj;
			$FORM_CONFIG[$MODULE_NAME_LOWER]=$json_obj;

			// Window & form panel.
			var $win_form_panel=document.createElement("div");

			// Form.
			$win_form_panel.appendChild(createForm($MODULE_NAME_LOWER));

			// Buttons.
			var $buttons_panel=document.createElement("div");
			Pennyutils.setClassName($buttons_panel, "tc");
			Pennyutils.setCssStyle($buttons_panel, "width:300px;");

			var $duplicate_button=document.createElement("button");
			Pennyutils.setClassName($duplicate_button, "l button");
			Pennyutils.events.addEventHandler($duplicate_button, "click", new Function("$($MODULE_NAME_LOWER+'._'+$MODULE_NAME_LOWER+'_id').value=''"));
			$duplicate_button.innerHTML=getResourceName("duplicate");
			$buttons_panel.appendChild($duplicate_button);

			var $submit_button=document.createElement("button");
			Pennyutils.setClassName($submit_button, "l button");
			Pennyutils.events.addEventHandler($submit_button, "click", updateDataAction);
			$submit_button.innerHTML=getResourceName("submit");
			$buttons_panel.appendChild($submit_button);

			var $clear_div=document.createElement("div");
			Pennyutils.setClassName($clear_div, "c");
			$buttons_panel.appendChild($clear_div);

			$win_form_panel.appendChild($buttons_panel);

			// Window.
			$FORM_WIN[$MODULE_NAME_LOWER]=createWindow();

			$FORM_WIN[$MODULE_NAME_LOWER].childNodes[1].appendChild($win_form_panel);

			document.body.appendChild($FORM_WIN[$MODULE_NAME_LOWER]);

			// Load datas.
			loadAllDatasAction();
		}, "&module_name_lower="+encodeURIComponent($MODULE_NAME_LOWER), true);
	} else {
		// var $form=createForm($MODULE_NAME_LOWER);
		// $("form_div").appendChild($form);

		// Load datas.
		loadAllDatasAction();
	}
}

window.addOnLoadListener(function () {
	var path = window.location.pathname;
	if(path[path.length - 1] != '/'){
		path = path.substring(0,path.lastIndexOf('/')+1)
	}
	new net.ContentLoader("dao/check_login.php", function(args){
		if(!JSON.parse(this.request.responseText).isLogin) window.location.href="login.html"
	});


		var $module_name_lower=getQueryString("module_name_lower");
		if ($module_name_lower) {
			changeModule($module_name_lower);
		}
		initLayout();
	}
);
window.addOnResizeListener(function(){
	initLayout();
});
function logout(){
	new net.ContentLoader("dao/logout.php", function(){
		document.cookie = "";
		window.location.href = "login.html";
	},"", true);
}
function initLayout () {

	var s = "";
	s+="\n document.body.clientWidth :"+ document.body.clientWidth ;
	s+="\n document.body.clientHeight :"+ document.body.clientHeight ;
	s+="\n document.documentElement.clientWidth :"+document.documentElement.clientWidth;
	s+="\n document.documentElement.clientHeight :"+document.documentElement.clientHeight;
	s+="\n document.body.offsetWidth :"+ document.body.offsetWidth ;
	s+="\n document.body.offsetHeight :"+ document.body.offsetHeight ;
	s+="\n document.body.scrollWidth :"+ document.body.scrollWidth ;
	s+="\n document.body.scrollHeight :"+ document.body.scrollHeight ;
	s+="\n document.body.scrollTop :"+ document.body.scrollTop ;
	s+="\n document.documentElement.scrollTop :"+ document.documentElement.scrollTop ;
	s+="\n document.body.scrollLeft :"+ document.body.scrollLeft ;
//	alert(s);

	$("right").style.width=(document.body.clientWidth-100)+"px";
	$("right").style.height=document.documentElement.clientHeight+"px";
}
//--><!]]>
</script>